package com.bosssoft.trainee.nontax.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bosssoft.trainee.nontax.common.Result;
import com.bosssoft.trainee.nontax.entity.po.Permission;
import com.bosssoft.trainee.nontax.mapper.PermissionMapper;
import com.bosssoft.trainee.nontax.service.IPermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author MaYunFei
 * @ProjectName RBAC_BOSS
 * @Description TODO
 * @time 2022/6/14 11:55
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {

    @Resource
    private PermissionMapper permissionMapper;


    @Override
    public Result<?> findPage(Integer pageNum, Integer pageSize, String search) {
        LambdaQueryWrapper<Permission> wrapper = Wrappers.lambdaQuery();
        if (StrUtil.isNotBlank(search)) {
            wrapper.like(Permission::getName, search);
        }
        Page<Permission> permissionPage = permissionMapper.selectPage(new Page<>(pageNum, pageSize), wrapper);
        return Result.success(permissionPage);
    }
}
